//package com.dragon.gencode.conf;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.DependsOn;
//import org.springframework.context.annotation.Primary;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.PlatformTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
//import javax.sql.DataSource;
//
////@Configuration
////@EnableTransactionManagement //启用多事物
//public class DataSourceConf {
//
//    @Bean(name = {"genDataSource","dataSource"})
//    @Primary
//    @ConfigurationProperties(prefix = "spring.datasource.gen")
//    public DataSource genDataSource() {
//        return new DruidDataSource();
//    }
//
//    @Bean(name = "genConfDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.gen-conf")
//    public DataSource genConfDataSource() {
//        return new DruidDataSource();
//    }
//
//    @Bean(name = {"genJdbcTemplate","jdbcTemplate"})
//    @Primary
//    @DependsOn({"genDataSource"})
//    public JdbcTemplate genJdbcTemplate(
//            @Qualifier("genDataSource") DataSource dataSource) {
//        return new JdbcTemplate(dataSource);
//    }
//
//    @Bean(name = "genConfJdbcTemplate")
//    @DependsOn({"genConfDataSource"})
//    public JdbcTemplate genConfJdbcTemplate(
//            @Qualifier("genConfDataSource") DataSource dataSource) {
//        return new JdbcTemplate(dataSource);
//    }
//
//    /**
//     * 数据源事务
//     * <code>
//     *     使用 @org.springframework.transaction.annotation.Transactional(transactionManager="platformTransactionManagerGenConf",rollbackFor = Exception.class)
//     * </code>
//     * @param dataSource dataSource
//     * @return PlatformTransactionManager
//     */
//    @Primary
//    @Bean({"platformTransactionManager","platformTransactionManagerGen"})
//    public PlatformTransactionManager platformTransactionManagerGen(@Qualifier("dataSource") DataSource dataSource) {
//        return new DataSourceTransactionManager(dataSource);
//    }
//
//    /**
//     * 数据源事务
//     * <code>
//     *     使用 @org.springframework.transaction.annotation.Transactional(transactionManager="platformTransactionManagerGenConf",rollbackFor = Exception.class)
//     * </code>
//     * @param dataSource genConfDataSource
//     * @return PlatformTransactionManager
//     *
//     */
//    @Bean("platformTransactionManagerGenConf")
//    public PlatformTransactionManager platformTransactionManagerGenConf(@Qualifier("genConfDataSource") DataSource dataSource) {
//        return new DataSourceTransactionManager(dataSource);
//    }
//}